// WARNING: This file has been generated. Any manual changes must be made within preserved regions or they will be lost.

//===============================================================================
//
// AssembliesTests
//
// PURPOSE: 
// Tests the functionality of Assemblies.
//
// NOTES: 
// 
//
//===============================================================================
//
// Copyright (C) 2003 Wallis Software Solutions
// All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//
//===============================================================================

using System.Reflection;
using NUnit.Framework;

namespace Agile.Common.Reflections.Tests
{
    /// <summary>
    /// Tests the functionality of Assemblies.
    /// </summary>
    [TestFixture]
    public class AssembliesTests
    {
        /// <summary>
        /// Verifies All assemblies are loaded when requested
        ///     - Check the array contains one of our items, Common
        ///     - Check the array contains nunit
        ///     - Check the array contains System
        /// </summary>
        [Test]
        public void AllAssembliesTests()
        {
            // Check all loaded assemblies contains Common
            Assert.IsTrue(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.AllLoadedAssemblies
                                                           , "Agile.Common")
                          , "Check all loaded assemblies contains Common");

            // Check all loaded assemblies contains nunit.framework
            Assert.IsTrue(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.AllLoadedAssemblies
                                                           , "nunit.framework")
                          , "Check all loaded assemblies contains nunit.framework");

            // Check all loaded assemblies contains System
            Assert.IsTrue(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.AllLoadedAssemblies
                                                           , "System")
                          , "Check all loaded assemblies contains System");
        }

        /// <summary>
        /// Verifies GetAssemblyNamed returns the required assembly
        ///     - use GetAssemblyNamed to get Agile.Common from OurAssemblies
        ///     - Check the assembly 
        ///     - use GetAssemblyNamed to get nunit.framework from AllAssemblies
        ///     - check the assembly
        /// </summary>
        [Test]
        public void GetAssemblyNamedTests()
        {
            // use GetAssemblyNamed to get Agile.Common from OurAssemblies
            Assembly common = Assemblies.GetAssemblyNamed(Assemblies.Instance.OurAssemblies, "Agile.Common");
            // Check the assembly is not null
            Assert.IsNotNull(common, "Check the assembly is not null");
            // use GetAssemblyNamed to get nunit.framework from AllAssemblies
            Assembly nunit = Assemblies.GetAssemblyNamed(Assemblies.Instance.AllLoadedAssemblies, "nunit.framework");
            // check the assembly
            Assert.IsNotNull(nunit, "Check the assembly is not null");
        }

        /// <summary>
        /// Verifies our assemblies return the right array of assemblies
        ///     - Check the array contains Agile.Common
        ///     - Check the array shouldn't contain Agile.WinUI
        ///     - Check the array contains Agile.Testing
        ///     - Check the array does not contain nunit
        ///     - Check the array does not contain System
        /// </summary>
        [Test]
        public void OurAssembliesTests()
        {
            // Check the array contains Agile.Common
            Assert.IsTrue(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.OurAssemblies
                                                           , "Agile.Common")
                          , "Check all loaded assemblies contains Agile.Common");

            // Check the array shouldn't contain Agile.UI
            Assert.IsFalse(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.OurAssemblies
                                                            , "Agile.WinUI")
                           , "Check all loaded assemblies shouldn't contain Agile.WinUUI");

            // Check the array does not contain nunit
            Assert.IsFalse(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.OurAssemblies
                                                            , "nunit.framework")
                           , "Check the array does not contain nunit");

            // Check the array does not contain System
            Assert.IsFalse(Assemblies.ContainsAssemblyNamed(Assemblies.Instance.OurAssemblies
                                                            , "System")
                           , "Check the array does not contain System");
        }
    }
}